package suncertify.db.test;

import java.util.Map;

import suncertify.contractors.Contractor;
import suncertify.db.Data;
import suncertify.remoting.RemoteContractorsAccessImpl;

public class ReadAllRecordsUser extends Thread {

    private Data data;
    private long[] records;
    private int iteration;

    public ReadAllRecordsUser(String name, Data data, int iterationCount) {

	super.setName(name);
	this.data = data;
	this.iteration = iterationCount;
    }

    public void run() {

	Map<Long, String[]> recordsMap = null;

	for (int i = 1; i <= this.iteration; ++i) {

	    // Data.log("", "================= ReadAllRecordsUser iteration  " + Integer.toString(i)
	    // + " ==================");

	    try {
		recordsMap = this.data.getAllRecords();

		// Data.log("", "ReadAllRecords count = " + Integer.toString(recordsMap.size()));

	    } catch (Exception ex) {

		// Data.log("", "====== ReadAllRecordsUser Exception = " + ex.getMessage());
		ex.printStackTrace();
	    }
	}
    }
}

class ReadAllRecordsUser2 extends Thread {

    private RemoteContractorsAccessImpl data;
    private long[] records;
    private int iteration;

    public ReadAllRecordsUser2(String name, RemoteContractorsAccessImpl data, int iterationCount) {

	super.setName(name);
	this.data = data;
	this.iteration = iterationCount;
    }

    public void run() {

	Contractor[] contractors = null;

	for (int i = 1; i <= this.iteration; ++i) {

	    // Data.log("", "================= ReadAllRecordsUser iteration  " + Integer.toString(i)
	    // + " ==================");

	    try {
		contractors = this.data.getAllContractors();

		// Data.log("", "ReadAllRecords count = " + Integer.toString(contractors.length));

	    } catch (Exception ex) {

		// Data.log("", "====== ReadAllRecordsUser Exception = " + ex.getMessage());
		ex.printStackTrace();
	    }
	}
    }
}

class ReadAllRecordsUser3 extends Thread {

    // private RemoteContractorsAccess access;
    private long[] records;
    private int iteration;

    public ReadAllRecordsUser3(String name, String serverName, int serverPort, int iterationCount) {

	super.setName(name);
	this.iteration = iterationCount;

	// try {
	// access = RmiClient.getContractorsAccess(serverName, serverPort);
	// } catch (ServerClientException e1) {
	// // Data.log("", "ServerClientException");
	// }
    }

    public void run() {

	Contractor[] contractors = null;

	for (int i = 1; i <= this.iteration; ++i) {

	    // Data.log("", "================= ReadAllRecordsUser3 iteration  " + Integer.toString(i)
	    // + " ==================");

	    try {
		// contractors = this.access.getAllContractors();

		// Data.log("", "ReadAllRecords3 count = " + Integer.toString(contractors.length));

	    } catch (Exception ex) {

		// Data.log("", "====== ReadAllRecordsUser3 Exception = " + ex.getMessage());
		ex.printStackTrace();
	    }
	}
    }
}